import Vue from "vue";
import Router from "vue-router";
import Layout from "@/layout/index.vue";

Vue.use(Router);

/**
 * Note: 路由配置项
 *
 * path：路由url
 *
 * name：路由别名
 *
 * component：按需导入组件
 */

// 公共路由
export const myRoutes = [
  {
    path: "",
    component: Layout,
    redirect: "",
    children: [
      {
        path: "",
        name: "Index",
        component: () => import("@/views/index/index.vue")
      },
      {
        path: "test",
        name: "Test",
        component: () => import("@/views/test/index.vue")
      }
    ]
  }
];

const router = new Router({
  routes: myRoutes,
  // 去掉url中的#
  mode: "history",
  base: "/",
  // 切换页面时，回到顶部
  scrollBehavior: () => ({
    y: 0,
  }),
});

export default router;
